package com.cg.servlet;

import com.cg.service.UserService;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;

@WebServlet("/user/remove")
public class RemoveUserServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String userName=req.getParameter("id");
        UserService service=new UserService();
        Boolean result=service.remove(userName);
        if (result){
            resp.sendRedirect(req.getContextPath()+"/user/list");
        }
    }
}
